/**
 * @name 权限
 */
layui.define(['larry', 'form', 'table','upload'], function(exports) {
    "use strict";
    var $ = layui.$,
    larry = layui.larry,
    form = layui.form,
    upload = layui.upload,
    table = layui.table;
    
    $.post("/backend/system/upms/role/selectRole",{},function(result){
    		for (var i = 0; i < result.data.length; i++) {
    			$("#roleId").append("<option value="+result.data[i]["roleId"]+">"+result.data[i]["name"]+"</option>");
		}
    		form.render('select');
    });
    
    //监听提交
    form.on('submit(addUser)', function(data) {
    		$.post("/backend/system/upms/user/addAdminUser",data.field,function(result){
    			if(result.status != 200){
    				layer.msg(result.msg);
    			} else {
    				parent.layer.closeAll();
			}
    		});
        return false;
    });
    
    
    //文件上传
    upload.render({
    	  elem: '#picture',
    	  url: '/Upload/layuiUpload', //必填项
    	  method: 'post',  //可选项。HTTP类型，默认post
    	  accept:'images',
    	  done: function(res, index, upload){
    		console.log();
    		$("#avatar").val(res.data["fullPath"]);
    		$("#avatarSrc").attr('src',res.data["downloadUrl"]); 
    	  }
    	});
    
    
  
    
    exports('mypanel', {});
});